﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace PloobsEngine.SceneControl
{

    public class SaturationPostEffect : IPostEffect
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="contrast">DEFAULT 1</param>
        public SaturationPostEffect(float saturation)
        {
            this.saturation = saturation;
        }

        #region IPostEffect Members

        Effect effect = null;

        float saturation = 0.5f;
        bool canChange = false;

        public bool CanChange
        {
            get { return canChange; }
            set { canChange = value; }
        }
        public float Saturation
        {
            get { return saturation; }
            set { saturation = value; }
        }

        public void Draw(IRenderHelper rHelper, Microsoft.Xna.Framework.GameTime gt, Microsoft.Xna.Framework.Rectangle screenRec, IWorld world)
        {

            if (canChange)
            {
                if(Keyboard.GetState().IsKeyDown(Keys.P))
                {
                    saturation+=0.1f;
                }
                else if(Keyboard.GetState().IsKeyDown(Keys.O))
                {
                    saturation-=0.1f;
                }

            }




            ///Draw a quad using the "effect", passing the CurrentImage as a Parameter            
            effect.Parameters["saturation"].SetValue(saturation);
            rHelper.RenderTextureToFullScreenSpriteBatch(PrincipalConstants.CurrentImage, effect);
        }

        public void init(EngineStuff engine)
        {
            ///Load the asset
            effect = EngineStuff.InternalContentManager.GetAsset<Effect>("saturation");
            //effect = EngineStuff.CustomContentManager.GetAsset<Effect>("..\\Content\\Effects\\saturation");          
        }

        #endregion

    }
}
